<?php
include('../../inc/global.inc');
include("../islogin.php");
$url=$_SERVER['HTTP_REFERER'];
//echo $url;

    $hot_arr = mysql_query("select * from member_hot where id =".$_GET["id"]);
    $hot_row = mysql_fetch_array($hot_arr);
    $hot_row?$ishot=1:$ishot=0;
            

if(!empty($_POST))
{

    
    $z1_arr=array(0=>0,1=>"时尚礼品、饰品",2=>"宠物与婴儿用品及玩具",3=>"纺织、服饰",4=>"农业",5=>"广告、办公、包装用品",6=>"家居与园艺",7=>"家具装饰",8=>"建筑、装修、装潢",9=>"医疗健康",10=>"体育休闲用品",11=>"计算机及消费电子",12=>"电子电工",13=>"机械设备、五金工具",14=>"交通运输及配件",15=>"化工、矿产");
//$z1=mysql_query("select * from hot_product where id='".$_POST["zuanshi1"]."'");
//$z1_row=mysql_fetch_array($z1);
    $z1_row["hot_name"]=$z1_arr[$_POST["zuanshi1"]];

    $z2=mysql_query("select * from hot_product where id='".$_POST["zuanshi2"]."'");
    $z2_row=mysql_fetch_array($z2);

    $z3=mysql_query("select * from hot_product where id='".$_POST["zuanshi3"]."'");
    $z3_row=mysql_fetch_array($z3);

 /*   if($ishot)
    {
        $z_sql="update member_hot set catalog_id1='".$_POST["zuanshi1"]."',catalog_1='".$z1_row["hot_name"]."',catalog_id2='".$_POST["zuanshi2"]."',catalog_2='".$z2_row["hot_name"]."',catalog_id3='".$_POST["zuanshi3"]."',catalog_3='".$z3_row["hot_name"]."' where id=" .$_POST["id"];
        
    }
    else
    {  */
    $z_sql = "insert into member_hot(id,catalog_id1,catalog_1,catalog_id2,catalog_2,catalog_id3,catalog_3) values (".$_POST["id"].",'".$_POST["zuanshi1"]."','".$z1_row["hot_name"]."','".$_POST["zuanshi2"]."','".$z2_row["hot_name"]."','".$_POST["zuanshi3"]."','".$z3_row["hot_name"]."')";
    mysql_query($z_sql);
    echo '<script>alert("添加成功");this.location.href="'.$_POST["url"].'";</script>';

}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type="text/javascript" src="/js/jquery.js"></script>
</HEAD>
<BODY>
<center>

  <table width="780" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">钻石会员选择热门推荐分类&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
<?php
$sql="select * from member where id=$_GET[id]";
$rs=mysql_query($sql);
$row=mysql_fetch_array($rs)
?>
 <form method="post" action="" name="form1">
<TABLE width="780" border="0" cellpadding="0" cellSpacing="1" bgcolor="#fff" >
        <tr><td style="width:200px" align="center" bgcolor="#8DA8CF"  height="45">用户名</td><td bgcolor="#8DA8CF"><?=$row["m_user"]?> 
<?php if($ishot){ ?>
【<?=$hot_row["catalog_1"]?>】 ----  【<?=$hot_row["catalog_2"]?>】 ---- 【<?=$hot_row["catalog_3"]?> 】
<?php } ?>
 </td></tr>
	 <tr>
        <td align="center" bgcolor="#8DA8CF"  height="45"><span style="padding-left:5px;">选择分类</span></td>
        
        <td bgcolor="#8DA8CF">
            	<select name="zuanshi1" id="zuanshi1" style="width:160px;">
					<option value="qingxuanze">请选择</option>
					<option value="14">交通运输及配件</option>
					<option value="11">计算机及消费电子</option>
					<option value="13">机械设备、五金工具</option>
					<option value="4">农业</option>
					<option value="15">化工、矿产</option>
					<option value="8">建筑、装修、装潢</option>
					<option value="3">纺织、服饰</option>
					<option value="1">时尚礼品、饰品</option>
					<option value="7">家具装饰</option>
					<option value="9">医疗健康</option>
					<option value="12">电子电工</option>
					<option value="10">体育休闲用品</option>
					<option value="2">宠物与婴儿用品及玩具</option>
					<option value="5">广告、办公、包装用品</option>
					<option value="6">家居与园艺</option>
				</select>
				<select name="zuanshi2" id="zuanshi2" style="width:160px;">
					<option value="qingxuanze" >请选择</option>
				</select>
				<select name="zuanshi2n" id="zuanshi2n" style="display:none">
					<?php
						$c2 = mysql_query("select id,hot_name,hot_ping,hot_id from hot_product where hot_id=0" );
						while($r2 = mysql_fetch_array($c2))
						{
					?>
					<option value="<?=$r2['id']?>" attr="<?=$r2['hot_ping']?>"><?=$r2['hot_name']?></option>
					<?php
						}
					?>
				</select>
				<select name="zuanshi3" id="zuanshi3" style="width:160px;">
					<option value="qingxuanze">请选择</option>
				</select>
				<select name="zuanshi3n" id="zuanshi3n" style="display:none">
					<?php
						$c3 = mysql_query("select id,hot_name,hot_ping,hot_id from hot_product where not hot_id=0" );
						while($r3 = mysql_fetch_array($c3))
						{
					?>
					<option value="<?=$r3['id']?>" attr="<?=$r3['hot_id']?>"><?=$r3['hot_name']?></option>
					<?php
						}
					?>
                </select>
                <input type="hidden" name="id" value="<?=$_GET["id"]?>">
                <input type="hidden" name="url" value="<?=$url?>">
                <input type="submit" value="添加"/>
        </td>
        
      </tr>              
</TABLE>
 </form>  
</center>
<script language="javascript">
$(function()
{
	$("#zuanshi1").change(function()
	{
		$("#zuanshi2").empty();
		$("#zuanshi2").append('<option value="qingxuanze">请选择</option>');
		$("#zuanshi1 option").each(function()
		{
			if($(this).attr("selected"))
			{
				var v = $(this).val();
				if(v!="qingxuanze")
				{
					$("#zuanshi2n option").each(function()
					{
						if($(this).attr("attr")==v)
						{
							$("#zuanshi2").append($(this).clone());
						}
					});
				}
			}
		}
		);
    });

	$("#zuanshi2").change(function()
	{
		$("#zuanshi3").empty();
		$("#zuanshi3").append('<option value="qingxuanze">请选择</option>');
		$("#zuanshi2 option").each(function()
		{
			if($(this).attr("selected"))
			{
				var v = $(this).val();
				if(v!="qingxuanze")
				{
					$("#zuanshi3n option").each(function()
					{
						if($(this).attr("attr")==v)
						{
							$("#zuanshi3").append($(this).clone());
						}
					});
				}
			}
		}
		);
	}
	);
});

</script>   
</BODY>
</HTML>


